﻿//========================================================================
// *作者：海盗猫  主页：ilplay.com
// *脚本：Attribute
// *描述：日志统一管理脚本，用于外接日志系统
// *?2021 MYJL . All rights reserved.
//* ======================================================================
using UnityEngine;

namespace HDMCode.UIFrame
{
    public enum LogSystem 
    {
        Store,
        UIDisplay,
        UIView,
        UIModle,
    }

    public static partial class UIFrame
    {
        public static void Log(string print,object outValue, LogSystem logSystem) 
        {
#if (HDMFRAME_LOG)
            ///框架的日志系统输出
            HDMCode.Log.Log.Write(GetLogPrint(print, outValue, logSystem));
#elif(UNITY_EDITOR)
            Debug.Log(GetLogPrint(print, outValue, logSystem));
#endif
        }

        public static void LogError(string print, object outValue, LogSystem logSystem)
        {
#if (HDMFRAME_LOG)
            ///框架的日志系统输出
            HDMCode.Log.Log.Error(GetLogPrint(print, outValue, logSystem));
            ///将异常同步到服务器
#else
            Debug.LogWarning(GetLogPrint(print, outValue, logSystem));
#endif
        }

        private static string GetLogPrint(string print, object outValue, LogSystem logSystem)
        {
            return logSystem switch
            {
                LogSystem.Store => $"<UIFrame 缓存器> 日志：{print} 值：{outValue}",
                LogSystem.UIDisplay => $"<UIFrame UI对象> 日志：{print} 值：{outValue}",
                LogSystem.UIView => $"<UIFrame 显示逻辑> 日志：{print} 值：{outValue}",
                LogSystem.UIModle => $"<UIFrame 框架系统> 日志：{print} 值：{outValue}",
                _ => ""
            };
        }
    }
}